home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / Universal Headers 2.0.1f / SoundInput.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-22  |  10.3 KB  |  256 lines  |  [TEXT/MMCC]

  1. /*
  2.      File:        SoundInput.h
  3.  
  4.      Contains:    Sound Input Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __SOUNDINPUT__
  21. #define __SOUNDINPUT__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __APPLEEVENTS__
  30. #include <AppleEvents.h>
  31. #endif
  32. /*    #include <Errors.h>                                            */
  33. /*    #include <Memory.h>                                            */
  34. /*        #include <MixedMode.h>                                    */
  35. /*    #include <OSUtils.h>                                        */
  36. /*    #include <Events.h>                                            */
  37. /*        #include <Quickdraw.h>                                    */
  38. /*            #include <QuickdrawText.h>                            */
  39. /*    #include <EPPC.h>                                            */
  40. /*        #include <AppleTalk.h>                                    */
  41. /*        #include <Files.h>                                        */
  42. /*        #include <PPCToolbox.h>                                    */
  43. /*        #include <Processes.h>                                    */
  44. /*    #include <Notification.h>                                    */
  45.  
  46. #ifndef __WINDOWS__
  47. #include <Windows.h>
  48. #endif
  49. /*    #include <Controls.h>                                        */
  50. /*        #include <Menus.h>                                        */
  51.  
  52. #ifndef __DIALOGS__
  53. #include <Dialogs.h>
  54. #endif
  55. /*    #include <TextEdit.h>                                        */
  56.  
  57. #ifndef __FILES__
  58. #include <Files.h>
  59. #endif
  60.  
  61. #ifndef __SOUND__
  62. #include <Sound.h>
  63. #endif
  64.  
  65. #ifdef __cplusplus
  66. extern "C" {
  67. #endif
  68.  
  69. #if PRAGMA_ALIGN_SUPPORTED
  70. #pragma options align=mac68k
  71. #endif
  72.  
  73. #if PRAGMA_IMPORT_SUPPORTED
  74. #pragma import on
  75. #endif
  76.  
  77.  
  78. enum {
  79.     siDeviceIsConnected            = 1,                            /*input device is connected and ready for input*/
  80.     siDeviceNotConnected        = 0,                            /*input device is not connected*/
  81.     siDontKnowIfConnected        = -1,                            /*can't tell if input device is connected*/
  82.     siReadPermission            = 0,                            /*permission passed to SPBOpenDevice*/
  83.     siWritePermission            = 1                                /*permission passed to SPBOpenDevice*/
  84. };
  85.  
  86. enum {
  87. /*Info Selectors for Sound Input Drivers*/
  88.     siActiveChannels            = 'chac',                        /*active channels*/
  89.     siActiveLevels                = 'lmac',                        /*active meter levels*/
  90.     siAGCOnOff                    = 'agc ',                        /*automatic gain control state*/
  91.     siAsync                        = 'asyn',                        /*asynchronous capability*/
  92.     siChannelAvailable            = 'chav',                        /*number of channels available*/
  93.     siCompressionAvailable        = 'cmav',                        /*compression types available*/
  94.     siCompressionFactor            = 'cmfa',                        /*current compression factor*/
  95.     siCompressionHeader            = 'cmhd',                        /*return compression header*/
  96.     siCompressionNames            = 'cnam',                        /*compression type names available*/
  97.     siCompressionType            = 'comp',                        /*current compression type*/
  98.     siContinuous                = 'cont',                        /*continous recording*/
  99.     siDeviceBufferInfo            = 'dbin',                        /*size of interrupt buffer*/
  100.     siDeviceConnected            = 'dcon',                        /*input device connection status*/
  101.     siDeviceIcon                = 'icon',                        /*input device icon*/
  102.     siDeviceName                = 'name',                        /*input device name*/
  103.     siHardwareBusy                = 'hwbs',                        /*sound hardware is in use*/
  104.     siInputGain                    = 'gain',                        /*input gain*/
  105.     siInputSource                = 'sour',                        /*input source selector*/
  106.     siInputSourceNames            = 'snam',                        /*input source names*/
  107.     siLevelMeterOnOff            = 'lmet',                        /*level meter state*/
  108.     siNumberChannels            = 'chan',                        /*current number of channels*/
  109.     siOptionsDialog                = 'optd',                        /*display options dialog*/
  110.     siPlayThruOnOff                = 'plth',                        /*playthrough state*/
  111.     siRecordingQuality            = 'qual',                        /*recording quality*/
  112.     siSampleRate                = 'srat',                        /*current sample rate*/
  113.     siSampleRateAvailable        = 'srav',                        /*sample rates available*/
  114.     siSampleSize                = 'ssiz',                        /*current sample size*/
  115.     siSampleSizeAvailable        = 'ssav',                        /*sample sizes available*/
  116.     siStereoInputGain            = 'sgai',                        /*stereo input gain*/
  117.     siTwosComplementOnOff        = 'twos',                        /*two's complement state*/
  118.     siVoxRecordInfo                = 'voxr',                        /*VOX record parameters*/
  119.     siVoxStopInfo                = 'voxs',                        /*VOX stop parameters*/
  120.     siInitializeDriver            = 'init',                        /*reserved for internal use only*/
  121.     siCloseDriver                = 'clos',                        /*reserved for internal use only*/
  122.     siPauseRecording            = 'paus',                        /*reserved for internal use only*/
  123.     siUserInterruptProc            = 'user',                        /*reserved for internal use only*/
  124. /*Qualities*/
  125.     siCDQuality                    = 'cd  ',                        /*44.1kHz, stereo, 16 bit*/
  126.     siBestQuality                = 'best',                        /*22kHz, mono, 8 bit*/
  127.     siBetterQuality                = 'betr',                        /*22kHz, mono, MACE 3:1*/
  128.     siGoodQuality                = 'good'
  129. };
  130.  
  131. typedef struct SPB SPB, *SPBPtr;
  132.  
  133. /*user procedures called by sound input routines*/
  134. /*
  135.         SIInterruptProcPtr uses register based parameters on the 68k and cannot
  136.         be written in or called from a high-level language without the help of
  137.         mixed mode or assembly glue.
  138.  
  139.             typedef pascal void (*SIInterruptProcPtr)(SPBPtr inParamPtr, Ptr dataBuffer, short peakAmplitude, long sampleSize);
  140.  
  141.         In:
  142.          => inParamPtr      A0.L
  143.          => dataBuffer      A1.L
  144.          => peakAmplitude    D0.W
  145.          => sampleSize      D1.L
  146. */
  147. typedef pascal void (*SICompletionProcPtr)(SPBPtr inParamPtr);
  148.  
  149. #if GENERATINGCFM
  150. typedef UniversalProcPtr SIInterruptUPP;
  151. typedef UniversalProcPtr SICompletionUPP;
  152. #else
  153. typedef Register68kProcPtr SIInterruptUPP;
  154. typedef SICompletionProcPtr SICompletionUPP;
  155. #endif
  156.  
  157. struct SPB {
  158.     long                            inRefNum;                    /*reference number of sound input device*/
  159.     unsigned long                    count;                        /*number of bytes to record*/
  160.     unsigned long                    milliseconds;                /*number of milliseconds to record*/
  161.     unsigned long                    bufferLength;                /*length of buffer in bytes*/
  162.     Ptr                                bufferPtr;                    /*buffer to store sound data in*/
  163.     SICompletionUPP                    completionRoutine;            /*completion routine*/
  164.     SIInterruptUPP                    interruptRoutine;            /*interrupt routine*/
  165.     long                            userLong;                    /*user-defined field*/
  166.     OSErr                            error;                        /*error*/
  167.     long                            unused1;                    /*reserved - must be zero*/
  168. };
  169. extern pascal NumVersion SPBVersion(void)
  170.  FOURWORDINLINE(0x203C, 0x0000, 0x0014, 0xA800);
  171. extern pascal OSErr SndRecord(ModalFilterUPP filterProc, Point corner, OSType quality, SndListHandle *sndHandle)
  172.  FOURWORDINLINE(0x203C, 0x0804, 0x0014, 0xA800);
  173. extern pascal OSErr SndRecordToFile(ModalFilterUPP filterProc, Point corner, OSType quality, short fRefNum)
  174.  FOURWORDINLINE(0x203C, 0x0708, 0x0014, 0xA800);
  175. extern pascal OSErr SPBSignInDevice(short deviceRefNum, ConstStr255Param deviceName)
  176.  FOURWORDINLINE(0x203C, 0x030C, 0x0014, 0xA800);
  177. extern pascal OSErr SPBSignOutDevice(short deviceRefNum)
  178.  FOURWORDINLINE(0x203C, 0x0110, 0x0014, 0xA800);
  179. extern pascal OSErr SPBGetIndexedDevice(short count, Str255 deviceName, Handle *deviceIconHandle)
  180.  FOURWORDINLINE(0x203C, 0x0514, 0x0014, 0xA800);
  181. extern pascal OSErr SPBOpenDevice(ConstStr255Param deviceName, short permission, long *inRefNum)
  182.  FOURWORDINLINE(0x203C, 0x0518, 0x0014, 0xA800);
  183. extern pascal OSErr SPBCloseDevice(long inRefNum)
  184.  FOURWORDINLINE(0x203C, 0x021C, 0x0014, 0xA800);
  185. extern pascal OSErr SPBRecord(SPBPtr inParamPtr, Boolean asynchFlag)
  186.  FOURWORDINLINE(0x203C, 0x0320, 0x0014, 0xA800);
  187. extern pascal OSErr SPBRecordToFile(short fRefNum, SPBPtr inParamPtr, Boolean asynchFlag)
  188.  FOURWORDINLINE(0x203C, 0x0424, 0x0014, 0xA800);
  189. extern pascal OSErr SPBPauseRecording(long inRefNum)
  190.  FOURWORDINLINE(0x203C, 0x0228, 0x0014, 0xA800);
  191. extern pascal OSErr SPBResumeRecording(long inRefNum)
  192.  FOURWORDINLINE(0x203C, 0x022C, 0x0014, 0xA800);
  193. extern pascal OSErr SPBStopRecording(long inRefNum)
  194.  FOURWORDINLINE(0x203C, 0x0230, 0x0014, 0xA800);
  195. extern pascal OSErr SPBGetRecordingStatus(long inRefNum, short *recordingStatus, short *meterLevel, unsigned long *totalSamplesToRecord, unsigned long *numberOfSamplesRecorded, unsigned long *totalMsecsToRecord, unsigned long *numberOfMsecsRecorded)
  196.  FOURWORDINLINE(0x203C, 0x0E34, 0x0014, 0xA800);
  197. extern pascal OSErr SPBGetDeviceInfo(long inRefNum, OSType infoType, void *infoData)
  198.  FOURWORDINLINE(0x203C, 0x0638, 0x0014, 0xA800);
  199. extern pascal OSErr SPBSetDeviceInfo(long inRefNum, OSType infoType, void *infoData)
  200.  FOURWORDINLINE(0x203C, 0x063C, 0x0014, 0xA800);
  201. extern pascal OSErr SPBMillisecondsToBytes(long inRefNum, long *milliseconds)
  202.  FOURWORDINLINE(0x203C, 0x0440, 0x0014, 0xA800);
  203. extern pascal OSErr SPBBytesToMilliseconds(long inRefNum, long *byteCount)
  204.  FOURWORDINLINE(0x203C, 0x0444, 0x0014, 0xA800);
  205. extern pascal OSErr SetupSndHeader(SndListHandle sndHandle, short numChannels, UnsignedFixed sampleRate, short sampleSize, OSType compressionType, short baseNote, unsigned long numBytes, short *headerLen)
  206.  FOURWORDINLINE(0x203C, 0x0D48, 0x0014, 0xA800);
  207. extern pascal OSErr SetupAIFFHeader(short fRefNum, short numChannels, UnsignedFixed sampleRate, short sampleSize, OSType compressionType, unsigned long numBytes, unsigned long numFrames)
  208.  FOURWORDINLINE(0x203C, 0x0B4C, 0x0014, 0xA800);
  209. enum {
  210.     uppSIInterruptProcInfo = kRegisterBased
  211.          | REGISTER_ROUTINE_PARAMETER(1, kRegisterA0, SIZE_CODE(sizeof(SPBPtr)))
  212.          | REGISTER_ROUTINE_PARAMETER(2, kRegisterA1, SIZE_CODE(sizeof(Ptr)))
  213.          | REGISTER_ROUTINE_PARAMETER(3, kRegisterD0, SIZE_CODE(sizeof(short)))
  214.          | REGISTER_ROUTINE_PARAMETER(4, kRegisterD1, SIZE_CODE(sizeof(long))),
  215.     uppSICompletionProcInfo = kPascalStackBased
  216.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SPBPtr)))
  217. };
  218.  
  219. #if GENERATINGCFM
  220. #define NewSIInterruptProc(userRoutine)        \
  221.         (SIInterruptUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSIInterruptProcInfo, GetCurrentArchitecture())
  222. #define NewSICompletionProc(userRoutine)        \
  223.         (SICompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSICompletionProcInfo, GetCurrentArchitecture())
  224. #else
  225. #define NewSIInterruptProc(userRoutine)        \
  226.         ((SIInterruptUPP) (userRoutine))
  227. #define NewSICompletionProc(userRoutine)        \
  228.         ((SICompletionUPP) (userRoutine))
  229. #endif
  230.  
  231. #if GENERATINGCFM
  232. #define CallSIInterruptProc(userRoutine, inParamPtr, dataBuffer, peakAmplitude, sampleSize)        \
  233.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSIInterruptProcInfo, (inParamPtr), (dataBuffer), (peakAmplitude), (sampleSize))
  234. #define CallSICompletionProc(userRoutine, inParamPtr)        \
  235.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSICompletionProcInfo, (inParamPtr))
  236. #else
  237. /* (*SIInterruptProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  238. #define CallSICompletionProc(userRoutine, inParamPtr)        \
  239.         (*(userRoutine))((inParamPtr))
  240. #endif
  241.  
  242.  
  243. #if PRAGMA_IMPORT_SUPPORTED
  244. #pragma import off
  245. #endif
  246.  
  247. #if PRAGMA_ALIGN_SUPPORTED
  248. #pragma options align=reset
  249. #endif
  250.  
  251. #ifdef __cplusplus
  252. }
  253. #endif
  254.  
  255. #endif /* __SOUNDINPUT__ */
  256.